package chai.ningning.chars;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * 1、java.io.Writer类的实例用来输出字符的输出流
 * 2、writer（int）/writer（char[]）/writer（char[],int,int）/writer(String)/writer(String,int,int)都是以字符为单位输出数据
 */
public class WriterTest1 {

    public static void main(String[] args) throws IOException {
        Writer w = new FileWriter("writer.txt");

        //w.write(ch)将指定字符（ch）写入到此输出流（w)
        w.write('a');
        w.write('b');
        w.write('\n');

        char[] chars = {'向','着','太','阳','生','长'};
        //依次序输出字符数组中的所以字符
        w.write(chars);
        w.write(10);
        w.write(chars,2,2);
        w.write(10);

        String s = "身处黑暗，心向光明";
        w.write(s);
        w.write(10);
        w.write(s,2,2);
        w.append( ' ');
        w.write(s,7,2);

        w.close();
    }
}
